<?php
if(!isset($_SESSION)){session_start();};

if($_GET['upload_bank_img']){

$uploaddir = '../styles/images/bank_images/'; 
$ext = substr($_FILES['uploadfile']['name'],strpos($_FILES['uploadfile']['name'],'.'));
$filename = $_FILES['uploadfile']['name']=time().$ext;
$file = $uploaddir . basename($filename); 

	if(isset($_SESSION['bank_img']) && unlink('../styles/images/bank_images/'.$_SESSION['bank_img'])){
		if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { 
			unset($_SESSION['bank_img']);		
			$_SESSION['bank_img'] = $filename;
			echo "success,".$filename; 
		} else {
			echo "error";
		}
	}else{
		if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { 
			$_SESSION['bank_img'] = $filename;
			echo "success,".$filename; 
		} else {
			echo "error";
		}
	}
}

if($_GET['upload_cat_img']){

$uploaddir = '../styles/images/category/'; 
$ext = substr($_FILES['uploadfile']['name'],strpos($_FILES['uploadfile']['name'],'.'));
$filename = $_FILES['uploadfile']['name']=time().$ext;
$file = $uploaddir . basename($filename); 

	if(isset($_SESSION['cat_img']) && unlink('../styles/images/category/'.$_SESSION['cat_img'])){
		if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { 
			unset($_SESSION['cat_img']);		
			$_SESSION['cat_img'] = $filename;
			echo "success,".$filename; 
		} else {
			echo "error";
		}
	}else{
		if (move_uploaded_file($_FILES['uploadfile']['tmp_name'], $file)) { 
			$_SESSION['cat_img'] = $filename;
			echo "success,".$filename; 
		} else {
			echo "error";
		}
	}
}
?>